<%@page import="com.demoweb.model.dto.Member"%>
<%@page import="com.demoweb.model.dto.CandyItem"%>
<%@page import="java.util.ArrayList"%>
<%@page import="com.demoweb.model.dto.Item"%>
<%@page import="com.demoweb.model.dto.Board"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>

<%!
/* String getTitleString(Board board) {
	
	StringBuilder html = new StringBuilder(256);
	if (board.isDeleted()) {
		html.append("<span style='color:gray' ");
		html.append("onclick=\"alert('삭제된 글입니다.');\">");
		html.append(board.getTitle());
		html.append("&nbsp;(삭제된 글)");
		html.append("</span>");
	} else {
		html.append("<a href='javascript:viewboard(");
		html.append(board.getBoardNo());
		html.append(");'>");
		html.append(board.getTitle());
		html.append("</a>");
	}
	
	return html.toString();
} */
%>
    
<!DOCTYPE html>

<html>
<head>
	<meta charset="utf-8" />
	<title>게시물 목록</title>
	<link rel="Stylesheet" href="/demoweb/styles/style.css" />
	<link rel="Stylesheet" href="/demoweb/styles/input.css" />
	<script type="text/javascript">
<%-- 	function viewboard(boardno) {
		
		<%
		String pageNo = request.getParameter("pageno");
		if (pageNo == null || pageNo.length() == 0)
			pageNo = "1";
		%>
		
		<% if (session.getAttribute("loginuser") != null) { %>
		location.href = 
			'view.action?boardno=' + boardno + "&pageno=<%= pageNo %>";
		<% } else { %>
		location.href = 
			"/demoweb/account/loginform.action?" + 
			"returnuri=/demoweb/board/view.action?boardno=" + 
			boardno + "&pageno=<%= pageNo %>";
		<% } %>
	} --%>
	
	

	</script>
</head>
<body>

	<% pageContext.include("/WEB-INF/views/include/candyheader.jsp"); %>

<div id="content">
  <div id="sidebar">

    <% pageContext.include("/WEB-INF/views/include/candylogin.jsp"); %>
	<% pageContext.include("/WEB-INF/views/include/fortressrecentupdates.jsp"); %>
  </div>
  

	<div id="pageContainer">

		<%
						Member member = (Member)session.getAttribute("loginuser");
		 				String usertype = "admin";
						
					%>	
		<div style="padding-top:25px;text-align:center">
<% if(member.getUserType().equals(usertype)) { %>
			<input type="button" value="글쓰기" 
				style="width:300px;height:25px"
				onclick="location.href='writeform.action';" /> <% } %>
			<br /><br />
	
					
					
					
			<%
			ArrayList<CandyItem> items = (ArrayList<CandyItem>)request.getAttribute("items");	
			%>		
			<% if (items != null && items.size() > 0) { %> 
			<table border="1" align="center">
				<tr style="background-color:beige;height:25px">
					<th style="width:50px">번호</th>
					<th style="width:300px">이미지</th>
					<th style="width:150px">아이템네임</th>
					<th style="width:120px">아이템설명</th>
					<th style="width:80px">인기</th>
				</tr>
			<% int count =1; %>	
			<% for (CandyItem item : items) { %>			
				<tr style="height:25px">
					<td style="text-align:center"><%if(member.getUserType().equals(usertype)){ %><input type="button" value="삭제" id="hotchart" name="hotchart" style="width:40px" onclick="location.href='/demoweb/candy/delete.action?itemno=<%= item.getItemNo() %>';" /> <%} %>
					<%= count++ %></td>
					<td style="text-align:center;padding:5px"><img src = "/demoweb/itemimages/<%= item.getItemFileName() %>">
					</td>
					<td style="text-align:center"><%= item.getItemTitle() %></td>
					<td style="text-align:center"><%= item.getContent() %></td>
					<td style="text-align:center">인기카운트[<%= item.getPopularityCount() %>]<br /><input type="button" value="투표하기" id="hotchart" name="hotchart" style="width:80px" onclick="location.href='increasepopularity.action?itemno=<%= item.getItemNo() %>';" />
					</td>
						
				</tr>
				  <%  }  %> 
			</table>
	 		<% } else { %> 
				<div style='text-align:center'>등록된 게시물이 없습니다.</div>
		     <% } %>
			<br /><br />
			
		<%-- 	<%= request.getAttribute("pager").toString() %> --%>
	
		</div>
	</div>
 </div>
</body>
</html>













